﻿using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using RestSharp;
using System.Configuration;
using System.Data;
using System.Windows;
using WpfApp1.Service;
using WpfApp1.Services;
using WpfApp1.ViewModel;

namespace WpfApp1
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        public new static App Current => (App)Application.Current;
        public IServiceProvider Services { get; }
        public App()
        {
            Services = ConfigureServices();

            this.InitializeComponent();
        }
        /// <summary>
        /// Configures the services for the application.
        /// </summary>
        private static IServiceProvider ConfigureServices()
        {
            var services = new ServiceCollection();

            services.AddSingleton<HttpRestClient>();  

            services.AddSingleton<ILoginUserService, LoginUserService>();
            services.AddTransient<MainViewModel>();
            Ioc.Default.ConfigureServices(services.BuildServiceProvider());

            return services.BuildServiceProvider();
        }
        //protected override void OnStartup(StartupEventArgs e)
        //{
           
           


        //}
    }

}
